package com.lcj.mis.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaMode;
import com.lcj.common.util.Result;
import com.lcj.mis.controller.form.DriverFineForm;
import com.lcj.mis.controller.form.SearchFineForm;
import com.lcj.mis.service.DriverFineService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

@RestController
@RequestMapping("/fine")
@Tag(name = "DriverFineController", description = "司机罚款管理Web接口")
public class DriverFineController {

    @Resource
    private DriverFineService driverFineService;

    @PostMapping("/addOrUpdateDriverFine")
    @SaCheckPermission(value = {"ROOT", "DRIVER_FINE:INSERT", "DRIVER_FINE:UPDATE"}, mode = SaMode.OR)
    @Operation(summary = "插入或更新司机罚款")
    public Result addOrUpdate(@RequestBody @Valid DriverFineForm form) {
        Result res = driverFineService.addOrUpdate(form);
        return res;
    }

    @PostMapping("/deleteDriverFine")
    @SaCheckPermission(value = {"ROOT", "DRIVER_FINE:DELETE"}, mode = SaMode.OR)
    @Operation(summary = "删除司机罚款")
    public Result delete(@RequestBody @Valid DriverFineForm form) {
        Result res = driverFineService.delete(form);
        return res;
    }

    @PostMapping("/searchFineByPage")
    @SaCheckPermission(value = {"ROOT", "DRIVER_FINE:SELECT"}, mode = SaMode.OR)
    @Operation(summary = "查询司机罚款")
    public Result select(@RequestBody @Valid SearchFineForm form) {
        Result res = driverFineService.select(form);
        return res;
    }

}